

package com.ruoyi.framework.listener;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.ruoyi.common.constant.MqQueueConstant;
import com.ruoyi.project.monitor.domain.SysLogininfor;
import com.ruoyi.project.system.domain.SysOrder;
import com.ruoyi.project.system.service.SysOrderService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.Date;


@Component
@RabbitListener(queues = "REDIRECT_QUEUE")
public class LogReceiveListener {


    @Autowired
    private SysOrderService sysOrderService;

    @RabbitHandler
    public void receive(Long orderId) {
        SysOrder sysOrder=sysOrderService.queryById(orderId);
        if(null!=sysOrder){
            if("1".equals(sysOrder.getPayStatus())){
                sysOrder.setPayStatus("0");
                sysOrder.setTimeout(new Date());
                sysOrder.setUpdateTime(new Date());
                sysOrderService.update(sysOrder);
                System.out.println("订单超时自动关闭"+sysOrder.getOrderId());
            }
        }

//        System.out.println("订单支付成功"+sysOrder.getOrderId());
    }
}

